package com.pig4cloud.pig.demo.Controller;

import com.pig4cloud.pig.common.core.util.R;
import com.pig4cloud.pig.common.security.annotation.Inner;
import com.pig4cloud.pig.demo.Service.ConlikeService;
import com.pig4cloud.pig.demo.Service.UserAndLikeService;
import com.pig4cloud.pig.demo.feign.Entity.Conlike;
import com.pig4cloud.pig.demo.feign.Entity.Userandlike;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Inner
public class ConlikeController {
    @Autowired
    private ConlikeService conlikeService;

    @Autowired
    private UserAndLikeService userAndLikeService;

    @GetMapping("/conlike/changeLikeNums/{uid}/{cid}")
    public R changeLikeNums(@PathVariable Long uid, @PathVariable Long cid) {
        Userandlike userandlike = conlikeService.changeLikeNums(uid, cid);
        if (userandlike == null)
            return R.failed();
        return R.ok(userandlike);
    }

//    @GetMapping("/conlike/getIsLiked/{uid}/{cid}")
//    public R getIsLiked(@PathVariable Long uid, @PathVariable Long cid) {
//        Userandlike userandlike = userAndLikeService.findByUidAndCid(uid, cid);
//        if (userandlike == null)
//            return R.failed();
//        return R.ok(userandlike);
//    }
}
